home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / java / io / Writer.class (.txt) < prev   
Encoding:
Java Class File  |  2006-11-29  |  1.8 KB  |  84 lines

  1. package java.io;
  2.  
  3. public abstract class Writer implements Appendable, Closeable, Flushable {
  4.    private char[] writeBuffer;
  5.    private final int writeBufferSize = 1024;
  6.    protected Object lock;
  7.  
  8.    protected Writer() {
  9.       this.lock = this;
  10.    }
  11.  
  12.    protected Writer(Object var1) {
  13.       if (var1 == null) {
  14.          throw new NullPointerException();
  15.       } else {
  16.          this.lock = var1;
  17.       }
  18.    }
  19.  
  20.    public void write(int var1) throws IOException {
  21.       synchronized(this.lock) {
  22.          if (this.writeBuffer == null) {
  23.             this.writeBuffer = new char[1024];
  24.          }
  25.  
  26.          this.writeBuffer[0] = (char)var1;
  27.          this.write((char[])this.writeBuffer, 0, 1);
  28.       }
  29.    }
  30.  
  31.    public void write(char[] var1) throws IOException {
  32.       this.write((char[])var1, 0, var1.length);
  33.    }
  34.  
  35.    public abstract void write(char[] var1, int var2, int var3) throws IOException;
  36.  
  37.    public void write(String var1) throws IOException {
  38.       this.write((String)var1, 0, var1.length());
  39.    }
  40.  
  41.    public void write(String var1, int var2, int var3) throws IOException {
  42.       synchronized(this.lock) {
  43.          char[] var5;
  44.          if (var3 <= 1024) {
  45.             if (this.writeBuffer == null) {
  46.                this.writeBuffer = new char[1024];
  47.             }
  48.  
  49.             var5 = this.writeBuffer;
  50.          } else {
  51.             var5 = new char[var3];
  52.          }
  53.  
  54.          var1.getChars(var2, var2 + var3, var5, 0);
  55.          this.write((char[])var5, 0, var3);
  56.       }
  57.    }
  58.  
  59.    public Writer append(CharSequence var1) throws IOException {
  60.       if (var1 == null) {
  61.          this.write("null");
  62.       } else {
  63.          this.write(var1.toString());
  64.       }
  65.  
  66.       return this;
  67.    }
  68.  
  69.    public Writer append(CharSequence var1, int var2, int var3) throws IOException {
  70.       Object var4 = var1 == null ? "null" : var1;
  71.       this.write(((CharSequence)var4).subSequence(var2, var3).toString());
  72.       return this;
  73.    }
  74.  
  75.    public Writer append(char var1) throws IOException {
  76.       this.write(var1);
  77.       return this;
  78.    }
  79.  
  80.    public abstract void flush() throws IOException;
  81.  
  82.    public abstract void close() throws IOException;
  83. }
  84.